package com.dm.mapper;

import com.dm.entity.Dormitory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author dancun
 * @since 2021-05-02
 */
@Mapper
@Repository
public interface DormitoryMapper extends BaseMapper<Dormitory> {
    @Results(id = "baseMap" ,value = {
            @Result(column = "did", property = "did"),
            @Result(column = "did", property = "manager",one=@One(select="com.dm.mapper.ManagerMapper.getByDID",fetchType= FetchType.EAGER))

    })
    @Select("select * from dormitory d left join manager m on d.did=m.did")
    public List<Dormitory> listDormitory();
    @ResultMap(value = "baseMap")
    @Select("select * from dormitory where id = #{id}")
    public Dormitory getOneDormitory(Integer id);

}
